#include "chatwindow.h"
#include "ui_chatwindow.h"

ChatWindow::ChatWindow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ChatWindow)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::Desktop);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->installEventFilter(new DragWidgetFilter(this));
    this->ui->send_message_pushButton->setEnabled(false);
}

ChatWindow::~ChatWindow()
{
    delete ui;
}

void ChatWindow::on_close_chat_toolButton_clicked()
{
    this->close();
}

void ChatWindow::on_textEdit_textChanged()
{
    this->sendMessage = this->ui->textEdit->toPlainText();
    if (this->sendMessage != nullptr && this->sendMessage.length() != 0)
    {
        this->ui->send_message_pushButton->setStyleSheet("background-color: green;");
        this->ui->send_message_pushButton->setEnabled(true);
    }
    else
    {
        this->ui->send_message_pushButton->setStyleSheet("background-color: rgb(162, 162, 162);");
        this->ui->send_message_pushButton->setEnabled(false);
    }

}

void ChatWindow::on_min_toolButton_clicked()
{
    this->showMinimized();
}

void ChatWindow::on_send_message_pushButton_clicked()
{
    qDebug() << "send message";
}
